use crate::config::Config;
use serde::{Deserialize , Serialize};

#[derive(Serialize,Deserialize,Debug)]
pub struct login {
    pub id :i32,
    pub username : String,
    pub password : String,
}

pub fn establish_connection(cfg: &Config) -> mysql_async::Pool {
    let database_url = &cfg.db.msn;
    let connect = mysql_async::Pool::new(database_url);
    connect
}

impl Clone for login {
    fn clone(&self) -> Self {
        login{
            id : self.id,
            username : self.username.clone(),
            password : self.password.clone(),
        }
    }

    fn clone_from(&mut self, source: &Self) {
        self.id = source.id;
        self.username = source.username.clone();
        self.password = source.password.clone();
    }
}